package cn.com.nes.site.module.service.crm;

import java.sql.Connection;
import java.sql.SQLException;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.com.nes.common.util.DBUtils;
import cn.com.nes.site.entity.DataReq;
import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.module.dao.crm.ClueDaoImpl;
@Service
public class ClueService {
	@Resource
	private ClueDaoImpl impl;

	public PageData getClueList(DataReq req)  {
		return impl.getClueList(req);
	}

	public PageData addClue(DataReq req) throws SQLException  {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.addClue(conn,req);
			conn.commit();
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}

	public PageData getClueByID(DataReq req)  {
		return impl.getClueByID(req);
	}

	public PageData getClueByPhone(DataReq req)  {
		return impl.getClueByPhone(req);
	}

	public PageData claimClue(DataReq req)  {
		return impl.claimClue(req);
	}

	public PageData getClueDetail(DataReq req) throws SQLException {
		return impl.getClueDetail(req);
	}

	public PageData addLogClaim(DataReq req) throws SQLException {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.addLogClaim(conn,req);
			conn.commit();
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;
	}

	public PageData deleteLogClaim(DataReq req)  {
		return impl.deleteLogClaim(req);
	}

	public PageData addClueAdvertisement(DataReq req)  {
		return impl.addClueAdvertisement(req);
	}

	public PageData deleteClueAdvertisement(DataReq req)  {
		return impl.deleteClueAdvertisement(req);
	}

	public PageData changeClueOwer(DataReq req)  {
		return impl.changeClueOwer(req);
	}

	public PageData returnClue(DataReq req)  {
		return impl.returnClue(req);
	}

	public PageData deleteClue(DataReq req)  {
		return impl.deleteClue(req);
	}

	public PageData addAdvertisement(DataReq req)  {
		return impl.addAdvertisement(req);
	}

	public PageData deleteAdvertisement(DataReq req)  {
		return impl.deleteAdvertisement(req);
	}

	public PageData getAdvertisement(DataReq req)  {
		return impl.getAdvertisement(req);
	}

	public PageData getDepartmentTree(DataReq req)  {
		return impl.getDepartmentTree(req);
	}

	public PageData saveToClue(DataReq req){
		return impl.saveToClue(req);
	}

	public PageData getActivityByID(DataReq req) throws SQLException{
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn = DBUtils.getJNDIDBConn();
			res = impl.getActivityByID(conn,req);
		}catch (Exception e) {
		}finally {
			if(conn!=null) conn.close();
		}
		return res ;

		//return impl.getActivityByID(req);
	}

	public String getAreaCodeByPhone(DataReq req){
		return impl.getAreaCodeByPhone(req);
	}

	public PageData getAdList(DataReq req) {
		return impl.getAdList(req);
	}

	public PageData getClueCheckCnt(DataReq req)  {
		return impl.getClueCheckCnt(req);
	}

	public PageData delCheckClue(DataReq req) throws SQLException {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn =DBUtils.getJNDIDBConn() ;
			res = impl.delCheckClue(conn,req);
			if(res.getRetCode()==0) {
				conn.commit();
			}
		}catch (Exception e) {
		}finally {
			if(conn!=null) {
				conn.rollback();
				conn.close();
			}
		}
		return res ;
	}

	public PageData claimClueMore(DataReq req) throws SQLException {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn =DBUtils.getJNDIDBConn() ;
			res = impl.claimClueMore(conn,req);
			if(res.getRetCode()==0) {
				conn.commit();
			}
		}catch (Exception e) {
		}finally {
			if(conn!=null) {
				conn.rollback();
				conn.close();
			}
		}
		return res ;
	}

	public PageData changeClueOwerMore(DataReq req) throws SQLException {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn =DBUtils.getJNDIDBConn() ;
			res = impl.changeClueOwerMore(conn,req);
			if(res.getRetCode()==0) {
				conn.commit();
			}
		}catch (Exception e) {
		}finally {
			if(conn!=null) {
				conn.rollback();
				conn.close();
			}
		}
		return res ;
	}

	public PageData getCheckin(DataReq req) throws SQLException {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn =DBUtils.getJNDIDBConn() ;
			res = impl.getCheckin(conn,req);
			if(res.getRetCode()==0) {
				conn.commit();
			}
		}catch (Exception e) {
		}finally {
			if(conn!=null) {
				conn.rollback();
				conn.close();
			}
		}
		return res ;
	}

	public PageData cancelCheckin(DataReq req) throws SQLException {
		Connection conn = null ;
		PageData res = new PageData() ;
		try {
			conn =DBUtils.getJNDIDBConn() ;
			res = impl.cancelCheckin(conn,req);
			if(res.getRetCode()==0) {
				conn.commit();
			}
		}catch (Exception e) {
		}finally {
			if(conn!=null) {
				conn.rollback();
				conn.close();
			}
		}
		return res ;
	}
}
